var general = {};

general.随机数 = function (minNum,maxNum) {
 
        switch(arguments.length){ 
            case 1: 
                return parseInt(Math.random()*minNum+1,10); 
            break; 
            case 2: 
                return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10); 
            break; 
                default: 
                    return 0; 
                break; 
        } 
    
}
general.进入同城 = function () {
    位置名="test"
    while(true){
        if (text('商城').exists()){
            log('在抖音首页')
       u= id('kqq').findOne()
          if (u.bounds().left<device.width/2){
         log('已在同城')
       
        if (id('u2e').textContains(位置名).exists()){
            log('城市正确')
            break
        }else{
            log('城市不对，换城市')
                   var a2 = id('u2e').findOne().bounds().centerX();
            var a3 = id('u2e').findOne().bounds().centerY();
            press(a2, a3, 1)   //press(x,y,1)
            sleep(1000)
            back()
            break
        }
          }else{
                        log('点同城|直播')
       id('tmk').findOne().click()
            sleep(3000)
          }
         
            
            
            
            
    
    }
    if (textContains('输入城市').exists()){
        log('切换城市')
        var a2 = textContains('输入城市').findOne().bounds().centerX();
        var a3 = textContains('输入城市').findOne().bounds().centerY();
        press(a2, a3, 1)   //press(x,y,1)
        sleep(1000)
         setText(位置名)
    }
    if (id('b02').exists()){
        log('确定选择')
        var a2 =id('b02').findOne().bounds().centerX();
        var a3 = id('b02').findOne().bounds().centerY();
        press(a2, a3, 1)   //press(x,y,1)
        sleep(1000)
         setText(位置名)
    }
    }
} 
    

module.exports = general;